require(["common", "coAjax", "jQuery", "queryString", "href", "routie"], function(jSouper, coAjax, $, QueryString, href, routie) {
	routie({
		"*": function() {
			var queryString = new QueryString(location.hash);
			//获取指定页的商品
			coAjax.get(appConfig.goods.list_with_page_info, {
				bus_id: appConfig.bus_id,
				num: ~~queryString.get("num") || 16,
				page: ~~queryString.get("page") || 0
			}, function(result) {
				App.set("$Cache.goods_info", result.result);
			}, function() {
				console.log(arguments);
			});
		}
	});

	var _search_ti;
	App.set("$Event.goods.search", function() {
		clearTimeout(_search_ti);
		_search_ti = setTimeout(function() {
			coAjax.get(appConfig.goods.search, {
				bus_id: appConfig.bus_id,
				q: App.get("$Cache.search_value")
			}, function(result) {
				App.set("$Cache.search_result", result.result);
			});
		}, 120);
	});
	var _unsearch_ti;
	App.set("$Event.goods.un_search", function() {
		clearTimeout(_unsearch_ti);
		_unsearch_ti = setTimeout(function() {
			App.set("$Cache.search_result", []);
		}, 200)
	});
	App.set("$Event.goods.scrollToFirstGoods", function() {
		$(window).scrollTop($("#goods").offset().top - 46);
	});
});